package io.renren.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;

import cn.hutool.core.util.StrUtil;
import io.renren.common.utils.ConvertUtils;
import io.renren.core.dao.LearnNewsDao;
import io.renren.core.dto.LearnNewsDTO;
import io.renren.core.entity.LearnNewsEntity;
import io.renren.core.service.LearnNewsService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 新闻资讯
 *
 * @author Ark 6980gong@gmail.com
 * @since 1.0.0 2024-04-29
 */
@Service
public class LearnNewsServiceImpl extends CrudServiceImpl<LearnNewsDao, LearnNewsEntity, LearnNewsDTO> implements LearnNewsService {

    @Override
    public QueryWrapper<LearnNewsEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<LearnNewsEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<LearnNewsDTO> listNewsLimit() {
        return ConvertUtils.sourceToTarget(baseDao.listNewsLimit(20), currentDtoClass());
    }
}